import request from '@/utils/request'

export function getRoutes() {
  return request({
    // url: '/vue-element-admin/routes',
    url: '/auth/getpermission',
    method: 'get'
  })
}

export function getRoles() {
  return request({
    // url: '/vue-element-admin/roles',
    url: '/auth/getroles',
    method: 'get'
  })
}

export function addRole(data) {
  return request({
    url: '/auth/addRole',
    method: 'post',
    data
  })
}

export function updateRole(id, data) {
  return request({
    url: `/auth/updateRole/${id}`,
    method: 'put',
    data
  })
}

export function deleteRole(id) {
  return request({
    url: `/auth/deleteRole/${id}`,
    method: 'delete'
  })
}

export function getPermissionByRole(roleId) {
  return request({
    url: '/auth/getPermissionByRoleId',
    method: 'get',
    params: { roleId }
  })
}

export function getPermissionByUserId(userId) {
  return request({
    url: '/auth/getPermissionByUserId',
    method: 'get',
    params: { userId }
  })
}
export function getRoleByUserId(userId) {
  return request({
    url: '/auth/getRoleByUserId',
    method: 'get',
    params: { userId }
  })
}